package domain;

import domain.PDU.PDU;

import java.util.Objects;

/**
 * @Author: ylc
 * @Description:SNMP报文
 */
public class Message {
    /**
     * 版本号
     */
    private String version;
    /**
     * 团体名
     */
    private String community;
    /**
     * PDU
     */
    private PDU pdu;

    public Message() {
    }

    public Message(String version, String community, PDU pdu) {
        this.version = version;
        this.community = community;
        this.pdu = pdu;
    }

    @Override
    public String toString() {
        return "Simple Network Management Protocol" +
                "\n version : " + version +
                "\n community : " + community +
                "\n data : " + pdu;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getCommunity() {
        return community;
    }

    public void setCommunity(String community) {
        this.community = community;
    }

    public PDU getPdu() {
        return pdu;
    }

    public void setPdu(PDU pdu) {
        this.pdu = pdu;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Message message = (Message) o;
        return Objects.equals(version, message.version) && Objects.equals(community, message.community) && Objects.equals(pdu, message.pdu);
    }

    @Override
    public int hashCode() {
        return Objects.hash(version, community, pdu);
    }
}
